#include <iostream>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string>
#include <fcntl.h>
using namespace std;
const string gpipefile = "./fifo";
const mode_t gmode = 0600;
const int gdefultfd = -1;
const int gsize = 1024;
const int gForRead=O_RDONLY;
const int gForWrite=O_WRONLY;


int Openfifo(int flag)
{
    //如果读端打开文件时，写端还没有打开，读端就会对用的open就会阻塞
    int fd = ::open(gpipefile.c_str(), flag);
    if (fd < 0)
    {
        cerr << "open error" << endl;
        return fd;
    }
    return fd;
}

void ClosefifoHelper(int fd)
{
    if (fd >= 0)
        ::close(fd);
}
